function before(n,fun){
  let result ;
  
  if(typeof fun !== 'function') throw new TypeError('Expected a function')
  return function(...arg){
    if(--n > 0){
      result = fun.apply(this,arg)
    }
    if(n <= 1){
      fun = undefined
    }
    return result
  }
}

//函数仅执行一次
function once(fun){
  before(2,fun)
}

// flow omit pipe pipeP pluck

export {
  before ,
  once ,
}